package com.herb.phoenix.models;

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Pool.Poolable;

public class Explosion implements Poolable
{
	private static final float DURATION = 0.5f;
	private static final float SMALL_DURATION = 0.2f;
	
	public Rectangle bounds = new Rectangle();
	public boolean alive;
	public float alpha, duration;
	
	public Explosion()
	{
		alive = false;
		duration = 0f;
		alpha = 0f;
	}
	
	public void init(float x, float y, float width, float height, boolean small)
	{
		bounds.x = x;
		bounds.y = y;
		bounds.width = width;
		bounds.height = width;
		
		if(small)
			duration = SMALL_DURATION;
		else
			duration = DURATION;
		
		alpha = 1f;
		alive = true;
	}
	
	public void init(float x, float y, float width, float height)
	{
		init(x, y, width, height, false);
	}
	
	@Override
	public void reset()
	{
		alive = false;
		duration = 0f;
		alpha = 0f;
	}
	
	public void update(float delta)
	{
		duration -= delta;
		alpha = duration/DURATION;
		
		if(duration <= 0)
			alive = false;
	}
	
}
